package com.videomeetting.legend.videomeetting.activity.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.videomeetting.legend.videomeetting.R;

import java.util.List;

/**
 * Created by legend on 18-7-1.
 */

public class TextChooseFragment extends DialogFragment implements View.OnClickListener{
    LinearLayout textLL;
    ImageView addIv;
    TextView title;
    List<String> rtsp=null;
    List<String> udp=null;
    List<String> rtmp=null;
    SharedPreferences sharedPreferences;

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        sharedPreferences = getActivity().getSharedPreferences("onlive", Context.MODE_PRIVATE);
        sharedPreferences.getString("rtsp","[]");
        sharedPreferences.getString("udp","[]");
        sharedPreferences.getString("rtmp","[]");
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        getDialog().getWindow().addFlags(Window.FEATURE_NO_TITLE);
        View view = inflater.inflate(R.layout.fragment_text_choose, container,false);//
        textLL = (LinearLayout) view.findViewById(R.id.fragment_text_choose_content_ll);
        addIv = (ImageView) view.findViewById(R.id.fragment_text_choose_add_iv);
        addIv.setOnClickListener(this);
        title = (TextView) view.findViewById(R.id.fragment_text_choose_title_tv);
        title.setText("地址本");

        String tag = getTag();
        switch (tag){
            case "rtsp":
                break;
            case "udp":
                break;
            case "rtmp":
                break;
        }
        return view;
    }

    @Override
    public void onDestroy() {

        super.onDestroy();

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.fragment_text_choose_add_iv:
                View view = View.inflate(getContext(), R.layout.text_choose_add_item, null);
                view.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,0,1));
                textLL.addView(view);
                break;
        }
    }
}
